package com.videoanswer.van.web.admin.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

public class LoginController {

    @RequestMapping(value = { "/login" }, method = { RequestMethod.GET })
	public ModelAndView getLogin(HttpServletRequest request,
			HttpServletResponse response, HttpSession session) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("hasMianNav", false);
		map.put("isLoginOrRegister", true);
		
		String loginFlag = request.getParameter("accountError");
		if(loginFlag != null && !loginFlag.isEmpty()&& loginFlag.equals("true")){
			map.put("loginError", true);
		}
		
		return new ModelAndView("/login", map);
	}
	
	@RequestMapping(value = { "/login" }, method = { RequestMethod.POST })
	public ModelAndView postLogin(HttpServletRequest request,
			HttpServletResponse response, HttpSession session) throws Exception{
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("hasMianNav", false);
		map.put("isLoginOrRegister", true);
		
		String loginFlag = request.getParameter("accountError");
		if(loginFlag != null && !loginFlag.isEmpty()&& loginFlag.equals("true")){
			map.put("loginError", true);
		}
		
		return new ModelAndView("/login", map);
	}

}
